//
//  RCFlyCell.m
//  RocketProject
//
//  Created by chen jiedan on 13-9-7.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "RCFlyCell.h"
#import "CommonDefines.h"
#import "UIColor-Expanded.h"


#define kLineImageFile          @"image_line_type3.png"
#define kBGImageFile            @"image_discount_cell_bg.png"
#define kArrowImageFile         @"flyTicket_orderCell_arrow.png"


@implementation RCFlyCell{
    UILabel *_startTime;
    UILabel *_endTime;
    UILabel *_pointPercent;
    UILabel *_lineLabel;
    UILabel *_airNumber;
    UILabel *_price;
    UIImageView *_arrowImageView;
    UIImageView *_lineImageView;
    
}


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        UIImage *bgImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:kBGImageFile ofType:nil]];
        [self setBackgroundColorWithImage:bgImage];
        self.backgroundColor = [UIColor clearColor];
        
        [self createPlaceHolder];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void) createPlaceHolder
{
    _startTime = [[UILabel alloc] initWithFrame:CGRectMake(15, 15, 155, 15)];
    _startTime.font = [UIFont fontWithName:kFontNameHelvetica size:15];
    _startTime.backgroundColor = [UIColor clearColor];
    _startTime.textColor = [UIColor colorWithRed:10.0/255 green:96.0/255 blue:180.0/255 alpha:1];
    [self.contentView addSubview:_startTime];
    [_startTime release];
    
    
//    _endTime = [[UILabel alloc] initWithFrame:CGRectMake(65, 18, 40, 12)];
//    _endTime.font = [UIFont fontWithName:kFontNameHelvetica size:12];
//    _endTime.backgroundColor = [UIColor clearColor];
//    _endTime.textColor = _startTime.textColor;
//    [self.contentView addSubview:_endTime];
//    [_endTime release];
    
    _pointPercent = [[UILabel alloc] initWithFrame:CGRectMake(130, 15, 140, 15)];
    _pointPercent.font = [UIFont fontWithName:kFontNameHelvetica size:14];
    _pointPercent.backgroundColor = [UIColor clearColor];
    _pointPercent.textColor = kNormalTextColor;
    [self.contentView addSubview:_pointPercent];
    [_pointPercent release];
    
    _pointPercent.hidden = YES;
    
    _lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 35, 250, 14)];
    _lineLabel.font = [UIFont fontWithName:kFontNameHeiti size:14];
    _lineLabel.backgroundColor = [UIColor clearColor];
    _lineLabel.textColor = kNormalHeadTextColor;
    [self.contentView addSubview:_lineLabel];
    [_lineLabel release];
    
    
    _airNumber = [[UILabel alloc] initWithFrame:CGRectMake(15, 60, 200, 14)];
    _airNumber.font = [UIFont fontWithName:kFontNameHelvetica size:14];
    _airNumber.backgroundColor = [UIColor clearColor];
    _airNumber.textColor = kNormalTextColor;
    [self.contentView addSubview:_airNumber];
    [_airNumber release];
    
    
    
    _price = [[UILabel alloc] initWithFrame:CGRectMake(220, 35, 66, 14)];
    _price.font = [UIFont fontWithName:kFontNameHelvetica size:14];
    _price.backgroundColor = [UIColor clearColor];
    _price.textColor = [UIColor colorWithRed:1 green:142.0/255 blue:48.0/255 alpha:1];
    _price.textAlignment = UITextAlignmentRight;
    [self.contentView addSubview:_price];
    [_price release];
    
    _arrowImageView = [[UIImageView alloc]initWithFrame:CGRectMake(296, 36, 10, 12)];
    _arrowImageView.backgroundColor = [UIColor clearColor];
    [_arrowImageView setImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:kArrowImageFile ofType:nil]]];
    [self.contentView addSubview:_arrowImageView];
    [_arrowImageView release];
    
    _lineImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 84, 320, 1)];
    _lineImageView.backgroundColor = [UIColor clearColor];
    [_lineImageView setImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:kLineImageFile ofType:nil]]];
    [self.contentView addSubview:_lineImageView];
    [_lineImageView release];
    
}

- (void) bindData:(RCPlaneItemDataModel *)item
{
    _startTime.text = item.time;
//    _endTime.text = @"08:30";
//    _pointPercent.text = @"准点率98%";
    _lineLabel.text = item.airportName;
    _airNumber.text = item.planeinfo;
    _price.text = [NSString stringWithFormat:@"￥%@",item.price];
    
}

@end
